import 'package:flutter/material.dart';
import 'package:ts_app_dart/screen/favorite_screen.dart';
import 'package:ts_app_dart/screen/home_page.dart';
import 'package:ts_app_dart/screen/profile_screen.dart';
import 'package:ts_app_dart/screen/setting_screen.dart';

class EntranceBottomBar extends StatefulWidget {
  const EntranceBottomBar({Key key}) : super(key: key);

  @override
  _EntranceBottomBarState createState() => _EntranceBottomBarState();
}

class _EntranceBottomBarState extends State<EntranceBottomBar> {
  final List<Widget> bodyPageList = [
    HomeScreen(),
    FavoriteScreen(),
    ProfileScreen(),
    SettingScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Two Paul'),
      ),
      drawer: Drawer(
        child: ListView(
          padding: EdgeInsets.zero,
          children: <Widget>[
            UserAccountsDrawerHeader(
              accountName: Text('Your Name'),
              accountEmail: Text('your.email@example.com'),
              currentAccountPicture: CircleAvatar(
                backgroundImage: NetworkImage(
                    'https://profile-avatar.csdnimg.cn/default.jpg'),
              ),
            ),
            ListTile(
              leading: Icon(Icons.home),
              title: Text('Home'),
              onTap: () {
                // Update the state of the app
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
            ListTile(
              leading: Icon(Icons.settings),
              title: Text('Settings'),
              onTap: () {
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
      body: bodyPageList[2],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: 0,
        onTap: (int index) {},
        iconSize: 30.0,
        fixedColor: Colors.red,
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
          BottomNavigationBarItem(
              icon: Icon(Icons.favorite_outlined), label: "收藏"),
          BottomNavigationBarItem(
              icon: Icon(Icons.library_add_check), label: "概述"),
          BottomNavigationBarItem(icon: Icon(Icons.settings), label: "设置")
        ],
      ),
    );
  }
}
